package com.yicong.ants.scenic.adapter

import android.graphics.Typeface
import androidx.core.view.isVisible
import com.chad.library.adapter.base.BaseQuickAdapter
import com.x.livesdk.BaseDataBindingHolder
import com.yicong.ants.R
import com.yicong.ants.databinding.ItemCityBinding
import com.yicong.ants.scenic.data.CityInfo

class CityChildAdapter() :
    BaseQuickAdapter<CityInfo.ChildArea, BaseDataBindingHolder<ItemCityBinding>>(
        R.layout.item_city
    ) {

    override fun getItemViewType(position: Int): Int {
        val data = getItem(position)
        val type = if (data?.id == "-1") {
            0
        } else {
            1
        }
        return type
    }

    var selectPosition = -1

    override fun convert(
        holder: BaseDataBindingHolder<ItemCityBinding>,
        item: CityInfo.ChildArea
    ) {
        holder.dataBinding?.textName?.textSize =
            if (holder.itemViewType == 0) {
                14f
            } else {
                12f
            }
        if (holder.itemViewType == 0) {
            holder.dataBinding?.textName?.typeface = Typeface.DEFAULT_BOLD
        } else {
            holder.dataBinding?.textName?.typeface = Typeface.DEFAULT
        }
        holder.dataBinding?.textName?.text = item.name
        holder.dataBinding?.imageTips?.isVisible = selectPosition == holder.layoutPosition
    }
}